package com.mes.check.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mes.basicdata.dao.iface.IOperationDao;
import com.mes.basicdata.dao.iface.IOperationMeasurementDao;
import com.mes.basicdata.domain.Operation;
import com.mes.basicdata.domain.OperationMeasurement;
import com.mes.check.dao.iface.ICheckBillDao;
import com.mes.check.dao.iface.ICheckBillDetailDao;
import com.mes.check.domain.CheckBill;
import com.mes.check.domain.CheckBillDetail;
import com.mes.common.dao.BasicDao;
import com.mes.common.util.SysUtil;
import com.mes.inventory.dao.iface.IMaterialDao;
import com.mes.inventory.domain.Material;
import com.mes.task.domain.OperationTask;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.hibernate.Session;


@Repository
public class CheckBillDetailDao extends BasicDao<CheckBillDetail> implements ICheckBillDetailDao {
	private static final Log log = LogFactory.getLog(CheckBillDetailDao.class);
	
	/**
	 * 获取某个检验要求的图示html
	 * @param checkTaskUid
	 * @return
	 * @throws Exception
	 */
	@Override
	public String getCheckPicHtml(String checkBillDetailUid) throws Exception {
		CheckBillDetail detail = this.getById(checkBillDetailUid);
		
		Session session = this.getSessionFactory().getCurrentSession();
		String sql = "select getcheckpic(?,?,?,?,?) from dual";
		Query query = session.createSQLQuery(sql);
		query.setString(0, detail.getMeasurementType());
		query.setString(1, detail.getStandardValue());
		query.setFloat(2, detail.getLbound());
		query.setFloat(3, detail.getUbound());
		query.setString(4, detail.getMeasureBase());
		String value = (String)query.uniqueResult();
		return value;
	}
	
	
	
}
